import React, { Dispatch, SetStateAction } from 'react';
import { PageContainer, PageContainerProps } from '@ant-design/pro-components';
import { PAGE_CONFIG } from '@/options';
import { Modal } from 'antd';
import { MSG } from '@/util/msg';

type MyPageContainerProps = {
  modelOk?: () => Promise<void> | void;
  modelCancel?: Dispatch<SetStateAction<boolean>>;
  content?: React.ReactNode;
  delMsgOpen?: boolean;
} & PageContainerProps;
const MyPageContainer: React.FC<MyPageContainerProps> = ({
  children,
  content = MSG.DELETE_TIP,
  delMsgOpen = false,
  modelOk,
  modelCancel,
  ...props
}) => {
  const onOk = () => {
    console.log('onOK');
    modelOk?.();
  };
  const onCancel = () => {
    // console.log('onCancel')
    modelCancel?.(false);
  };
  return (
    <PageContainer {...PAGE_CONFIG} {...props}>
      <div>{children}</div>
      <Modal open={delMsgOpen} onCancel={onCancel} onOk={onOk}>
        {content}
      </Modal>
    </PageContainer>
  );
};

export default MyPageContainer;
